package com.qf.qfssm.web.master.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.UUID;

/**
 * @author 刘欣
 * @createTime 2023/1/10 15:23
 * @description
 */
@Slf4j
public class FileUtils {

    public static File createFile(MultipartFile multipartFile, String filedir) {
        String prefix = UUID.randomUUID().toString();
        String originalFilename = multipartFile.getOriginalFilename();
        String finalFilePath = prefix + "_" + originalFilename;
        File file = new File(filedir + finalFilePath);
        log.debug("文件已创建，路径为：", file.getAbsolutePath());
        return file;
    }
}
